package com.skycong.hello77.activity.frag;

import android.app.Activity;
import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Window;
import com.skycong.hello77.R;
import com.skycong.hello77.fragment.ContentFragment;
import com.skycong.hello77.fragment.TitleFragment;


public class MyFragActivity extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        setContentView(R.layout.activity_fragment);

        /*
         * 动态的添加fragment
         * 1,创建Fragment的管理器对象
         * 2，获取Fragment的事务对象并开启事务
         * 3，调用事务中响应的动态操作Fragment的方法执行
         * 4，提交事务
         *add(,INter)
         *
         * */

        FragmentManager supportFragmentManager = this.getSupportFragmentManager();
        FragmentTransaction transaction = supportFragmentManager.beginTransaction();
        transaction.add(R.id.title_layout, new TitleFragment());
        transaction.add(R.id.content_layout,new ContentFragment());
        //提交事务
        transaction.commit();

    }
}
